package com.three.iot.commons.enums;

import java.util.Objects;

/**
 * @author luiz
 * @Title: ResultCode
 * @ProjectName iot
 * @Description: 字典类型枚举
 * @date 2019-04-03 16:00
 */
public enum DictTypeEnum {
    DEVICE_GROUP("DEVICE_GROUP", "设备分组"),
    ATTR_DATA_TYPE("ATTR_DATA_TYPE", "属数据类型"),
    ATTR_UNIT("ATTR_UNIT", "属性单位"),
    SHOW_TYPE("SHOW_TYPE", "显示样式"),
    ;

    String code;
    String name;

    DictTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static final DictTypeEnum matching(String code) {
        for (DictTypeEnum resultCode : DictTypeEnum.values()) {
            if (Objects.equals(resultCode.getCode(), code)) return resultCode;
        }
        return null;
    }
}
